import { useState, useCallback } from 'react'
import { queryConfig, typeFlag } from '@/api/config'

const useGlobalConfig = () => {
  const [carTypes, setCarTypes] = useState([])
  const [carBrands, setCarBrands] = useState([])
  const getCarTypes = useCallback(async () => { // 车辆类型
    const res = await queryConfig(typeFlag.carType)
    setCarTypes(res?.data || [])
  }, [])
  const getCarBrands = useCallback(async () => { // 车辆品牌
    const res = await queryConfig(typeFlag.carBrand)
    setCarBrands(res?.data || [])
  }, [])
  return {
    getCarTypes,
    carTypes,
    getCarBrands,
    carBrands
  }
}

export default useGlobalConfig
